package org.zxp.onedoteight.base64test;

import java.io.UnsupportedEncodingException;
import java.util.Base64;

/**
 * @program: effectiveJava
 * @description:
 * @author: X-Pacific zhang
 * @create: 2020-03-12 16:40
 **/
public class Base64Test {
    public static void main(String[] args) throws UnsupportedEncodingException {
        Base64.Encoder encoder = Base64.getEncoder();
        Base64.Decoder decoder = Base64.getDecoder();

        String text = "123456";

        byte[] b = text.getBytes("UTF-8");
        String textEn = encoder.encodeToString(b);
        System.out.println(textEn);
        String textDe = new String( decoder.decode(textEn),"UTF-8");
        System.out.println(textDe);
    }
}
